<!--
 * @Description: 管理系统首页
 * @Author: zhihong deng
 * @Date: 2021-07-28 22:13:38
 * @LastEditors: zhihong deng
 * @LastEditTime: 2021-07-29 15:30:41
-->
<template>
  <el-container>
    <el-header>
      <el-row>
        <el-col :span="2">
          <div class="grid-content bg-purple-dark">
            后台管理系统
          </div>
          </el-col>
        <el-col :offset="20" :span="2">
          <el-button type="info" @click="logOut">
            退出
          </el-button>
        </el-col>
      </el-row>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
          :router="routerStatues"
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b">

          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="/users">用户列表</el-menu-item>
              <el-menu-item index="/useradd">用户添加</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-menu"></i>
              <span slot="title">商品管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="2-1">商品列表</el-menu-item>
              <el-menu-item index="2-2">商品添加</el-menu-item>
            </el-menu-item-group>
          </el-submenu>

        </el-menu>
      </el-aside>
      <el-main>
        <!-- 嵌套路由 -->
        <router-view/>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data () {
    return {
      routerStatues: true
    }
  },
  methods:{
    logOut () {
      // 1.清除本地缓存的token
      localStorage.removeItem('cmsToken');
      // 2.前往登录页面
      this.$router.push('/login')
    }
  }
}
</script>

<style scope>
  .el-header, .el-footer {
    background-color: #B3C0D1;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>